/*
 * @Author: 谢子健 1075010289@qq.com
 * @Date: 2024-09-17 13:29:44
 * @LastEditors: 谢子健 1075010289@qq.com
 * @LastEditTime: 2024-09-17 13:29:54
 * @FilePath: \ilink-vue-frontend\src\stores\useStudyTreeStore.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
// src/store/useStudyTreeStore.ts
import { defineStore } from "pinia";

// 定义单个技能树项的接口
export interface StudyTreeItem {
  id: string;
  name: string;
  description: string;
  imageUrl: string;
  jsonContent: string;
  createdAt: string;
  updatedAt: string;
}

interface StudyTreeState {
  clickedNodeLabel: string | null;
  jsonContent: any | null;
  studyTreeItems: StudyTreeItem[];
  totalItems: number;
}

export const useStudyTreeStore = defineStore("studyTreeStore", {
  state: (): StudyTreeState => ({
    clickedNodeLabel: null,
    jsonContent: null,
    studyTreeItems: [],
    totalItems: 0,
  }),
  actions: {
    setClickedNodeLabel(label: string) {
      this.clickedNodeLabel = label;
    },

    setJsonContent(content: any) {
      this.jsonContent = content;
    },

    setStudyTreeItems(items: StudyTreeItem[], total: number) {
      this.studyTreeItems = items;
      this.totalItems = total;
    },
  },
});
